const CompressionWebpackPlugin = require('compression-webpack-plugin');
const productionGzipExtensions = ['js', 'css'];
const path = require('path');
module.exports = {
  publicPath: './',
  outputDir: 'ppm',
  assetsDir: 'static',
  productionSourceMap: false, // 生产环境是否生成 sourceMap 文件
  configureWebpack: {

    performance: {
      hints: 'warning',
      maxEntrypointSize: 50000000,
      maxAssetSize: 30000000,
      assetFilter: function(assetFilename) {
        return assetFilename.endsWith('.js')
      }
    },
    plugins: [
      new CompressionWebpackPlugin({
        filename: '[path].gz[query]',
        algorithm: 'gzip',
        test: new RegExp(`\\.(${productionGzipExtensions.join('|')})$`),
        threshold: 10240,
        minRatio: 0.8
        // deleteOriginalAssets: true// 是否删除原资源
      })
    ],
    module: {
      rules: [
        {
          test: /\.vue$/,
          exclude: /node_modules/,
          loader: path.resolve(__dirname, './src/plugins/clearConsole.js')
        },
        {
          test: /\.js$/,
          exclude: /node_modules/,
          loader: path.resolve(__dirname, './src/plugins/clearConsole.js')
        }
      ]
    }
  },
  css: {
    loaderOptions: {
      // postcss: {
      // 	plugins: [
      // 		require("postcss-pxtorem")({
      // 			//这里是配置项，详见官方文档
      // 			rootValue: 20, // 换算的基数
      // 			selectorBlackList: ["mu"], // 忽略转换正则匹配项
      // 			propList: ["*"],
      //       exclude:'/node-modules/i'
      // 		}),
      // 	],
      // },
      less: {
        // If you are using less-loader@5 please spread the lessOptions to options directly
        // modifyVars: {
        // 	"primary-color": "#202440",
        // },
        // javascriptEnabled: true,
      }
    }
  }
}
